﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Diagnostics;

namespace TruckingApplication.Web.Helpers
{
    public class MvcBasicLog
    {
        public static string _logSource { get; set; }

        public static void AddLogLine(string logMessage, bool isError)
        {
            EventLog log = new EventLog();
            log.Source = _logSource;
            //
            try
            {
                log.WriteEntry(logMessage, (isError ? EventLogEntryType.Error : EventLogEntryType.Information));
            }
            catch (System.Security.SecurityException ex)
            {
                //
                // In Web app you do not have right to create event log source and
                // the log source must be created first by using the provided CreateEventLogEntry project!
                //
                throw new ApplicationException("You must create the event log entry for our source by using CreateEventLogEntry project!", ex);
            }
            catch
            {
                //
                // The log file is to large, so clear it first.
                //
                log.Clear();
                log.WriteEntry(logMessage, (isError ? EventLogEntryType.Error : EventLogEntryType.Information));
            }
            //
            log.Close();
        }

        public void LogError(string category, string message)
        {

        }

        public void LogError(string message)
        {

        }

        public void LogException(Exception ex)
        {

        }

        public void LogException(string category, Exception ex)
        {

        }

        public void LogMessage(string category, string message)
        {

        }

        public void LogMessage(string message)
        {

        }
    }
}